local M = {}
function M.createKernel()
	local kernel = {
		category = "filter",
		name = "alpha_roll",
		isTimeDependent = true,
		vertexData = 
		{
			{
				name = "speed", 
				default = 0.08, 
				min = 0, 
				max = 1, 
				index = 0, -- This corresponds to "CoronaVertexUserData.x"
			}, 
			{
				name = "offset", 
				default = 0, 
				index = 1, -- This corresponds to "CoronaVertexUserData.x"
			}, 
		},
		fragment = 
		[[
		P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
		{
			P_DEFAULT vec2 uv = vec2(texCoord.x, mod((texCoord.y-CoronaTotalTime*CoronaVertexUserData.x+CoronaVertexUserData.y)*3.0,1.0));
			P_DEFAULT vec4 texColor = texture2D( CoronaSampler0, texCoord);
			texColor.rgb *= 0.3;
			return CoronaColorScale(texColor);
		}
		]],
	}

	return kernel
end


function M.init()
	local kernel = M.createKernel()
	graphics.defineEffect(kernel)
end

M.init()


function M.test()
	local bgRect = display.newRect(SCREEN_CX, SCREEN_CY, SCREEN_W, SCREEN_H)
	local ground = display.newImage("assets/unpack/bg/bg_main.png")
	ground.anchorY = 0
	layout.setXY(ground, SCREEN_CX,0)
	ground.fill.effect = "filter.custom.alpha_roll"
	ground.fill.effect.speed = 0.03
end

return M